/* =====================================================
PRODUCT IMAGE ICON & MODAL STYLES
===================================================== */

/* Product Image Icon (next to product name) */
.product-image-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    color: #489292;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

.product-image-icon:hover {
    color: #3a7575;
    transform: scale(1.1);
}

.product-image-icon:active {
    transform: scale(0.95);
}

.product-image-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

/* Product Image Modal */
.product-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.product-image-modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.product-image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.product-image-modal-content {
    position: relative;
    width: min(460px, 92vw);
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 46px 14px 14px;
    z-index: 1;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(17, 24, 39, 0.10);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.product-image-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: rgba(17, 24, 39, 0.06);
    border: 1px solid rgba(17, 24, 39, 0.12);
    border-radius: 50%;
    color: #111827;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.product-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.product-image-modal-close:active {
    transform: scale(0.95);
}

.product-image-container {
    width: 100%;
    max-width: 100%;
    max-height: calc(78vh - 60px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.product-image-container img {
    max-width: 100%;
    max-height: calc(78vh - 140px);
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(17, 24, 39, 0.10);
}

.product-image-name {
    color: #111827;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    padding: 10px 12px;
    background: rgba(17, 24, 39, 0.04);
    border-radius: 12px;
    max-width: 100%;
}

/* Product Image Error State */
.product-image-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
}

.product-image-error svg {
    color: rgba(255, 255, 255, 0.6);
    opacity: 0.7;
}

.product-image-error p {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

.product-image-error-subtitle {
    font-size: 14px !important;
    font-weight: 400 !important;
    opacity: 0.7;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .product-image-icon {
        width: 18px;
        height: 18px;
        min-width: 18px;
        min-height: 18px;
    }
    
    .product-image-modal-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 20px;
    }
    
    .product-image-container {
        max-width: 100%;
        max-height: calc(72vh - 60px);
    }
    
    .product-image-container img {
        max-height: calc(72vh - 140px);
    }
    
    .product-image-name {
        font-size: 14px;
        padding: 10px 12px;
    }
}

/* Product Image Icon - Upload Mode (when secret is active but no image) */
.product-image-icon-upload {
    color: #9ca3af;
    opacity: 0.7;
}

.product-image-icon-upload:hover {
    color: #489292;
    opacity: 1;
}

/* Touch-friendly sizing */
@media (pointer: coarse) {
    .product-image-icon {
        width: 22px;
        height: 22px;
        min-width: 22px;
        min-height: 22px;
    }
}

/* =====================================================
IMAGE UPLOAD MODAL STYLES (Admin Feature)
===================================================== */

/* Image Upload Modal */
.image-upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-upload-modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.image-upload-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.image-upload-modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-upload-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.image-upload-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.image-upload-modal-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #6b7280;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-upload-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.image-upload-modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.image-upload-product-name {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

/* Current Image Preview */
.current-image-preview {
    margin-bottom: 24px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.current-image-label {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 12px;
}

.current-image-display {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    margin-bottom: 12px;
    display: block;
}

/* Upload Options */
.image-upload-options {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.image-upload-options .btn-primary,
.image-upload-options .btn-secondary {
    flex: 1;
    min-width: 140px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.image-upload-options .btn-primary {
    background: #489292;
    color: white;
}

.image-upload-options .btn-primary:hover:not(:disabled) {
    background: #3a7575;
}

.image-upload-options .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.image-upload-options .btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.image-upload-options .btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.image-upload-options label.btn-secondary {
    cursor: pointer;
    margin: 0;
}

/* Preview Before Save */
.image-preview-before-save {
    margin-top: 24px;
    padding: 16px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
}

.preview-label {
    font-size: 14px;
    font-weight: 500;
    color: #0369a1;
    margin-bottom: 12px;
}

.preview-image-display {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 8px;
    margin-bottom: 16px;
    display: block;
    border: 2px solid #bae6fd;
}

.preview-actions {
    display: flex;
    gap: 12px;
}

.preview-actions .btn-primary,
.preview-actions .btn-secondary {
    flex: 1;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preview-actions .btn-primary {
    background: #489292;
    color: white;
}

.preview-actions .btn-primary:hover:not(:disabled) {
    background: #3a7575;
}

.preview-actions .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.preview-actions .btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.preview-actions .btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Loading State */
.image-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
}

.image-loading-state .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #489292;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.image-loading-state p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Delete Button */
.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Auto-Find Results Modal */
.auto-find-results-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auto-find-results-modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.auto-find-results-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.auto-find-results-modal-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.auto-find-results-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.auto-find-results-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.auto-find-results-modal-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #6b7280;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.auto-find-results-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.auto-find-results-content {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.auto-find-result-item {
    cursor: pointer;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    background: white;
}

.auto-find-result-item:hover {
    border-color: #489292;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 146, 146, 0.2);
}

.auto-find-image-container {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auto-find-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auto-find-image-title {
    padding: 8px;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

/* Mobile optimizations for upload modal */
@media (max-width: 768px) {
    .image-upload-modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .image-upload-modal-body {
        padding: 16px;
        max-height: calc(95vh - 80px);
    }
    
    .image-upload-options {
        flex-direction: column;
    }
    
    .image-upload-options .btn-primary,
    .image-upload-options .btn-secondary {
        width: 100%;
    }
    
    .preview-actions {
        flex-direction: column;
    }
    
    .auto-find-results-content {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
        padding: 16px;
    }
}
